package ma.ensao.egicom.core.model;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.scub.foundation.framework.core.model.BaseModel;


@Entity
@Table(name = "marketorder", schema = "public")
public class Marketorder extends BaseModel {

    private Customer customer;

    private Date orderdate;

    private String delivryadr;

    private String factureadr;

    @OneToMany(fetch = FetchType.EAGER)
    @JoinColumn(name = "marketorderid", referencedColumnName = "ID")
    private Set<Marketorderline> marketorderlines = new HashSet(0);

    public Marketorder() {
    }

    public Marketorder(Customer customer, Date orderdate, String delivryadr, String factureadr, Set marketorderlines) {
        this.customer = customer;
        this.orderdate = orderdate;
        this.delivryadr = delivryadr;
        this.factureadr = factureadr;
        this.marketorderlines = marketorderlines;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "customerid", nullable = false)
    public Customer getCustomer() {
        return this.customer;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    @Temporal(TemporalType.DATE)
    @Column(name = "orderdate", length = 13)
    public Date getOrderdate() {
        return this.orderdate;
    }

    public void setOrderdate(Date orderdate) {
        this.orderdate = orderdate;
    }

    @Column(name = "delivryadr", length = 25)
    public String getDelivryadr() {
        return this.delivryadr;
    }

    public void setDelivryadr(String delivryadr) {
        this.delivryadr = delivryadr;
    }

    @Column(name = "factureadr", length = 25)
    public String getFactureadr() {
        return this.factureadr;
    }

    public void setFactureadr(String factureadr) {
        this.factureadr = factureadr;
    }

    public Set<Marketorderline> getMarketorderlines() {
        return this.marketorderlines;
    }

    public void setMarketorderlines(Set<Marketorderline> marketorderlines) {
        this.marketorderlines = marketorderlines;
    }

    @Override
    public boolean equals(Object other) {
        // TODO Auto-generated method stub
        return false;
    }

}
